home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / calloc.c < prev    next >
C/C++ Source or Header  |  1992-05-15  |  744b  |  32 lines

  1. /* from the TOS GCC library */
  2. /* malloc, free, realloc: dynamic memory allocation */
  3. /* 5/2/92 sb -- modified for Heat-n-Serve C to accomodate its 16-bit size_t */
  4. /* 5/5/92 sb -- calloc() gets its own file to reduce library drag */
  5.  
  6. #include <stddef.h>    /* for size_t */
  7. #include <memory.h>
  8. #include <string.h>
  9.  
  10. __EXTERN void *_malloc __PROTO((unsigned long));
  11. __EXTERN void _bzero __PROTO((void *, unsigned long));
  12.  
  13. void * _calloc(n, sz)
  14. unsigned long n, sz;
  15. {
  16.   void *r;
  17.   unsigned long total;
  18.   extern void _bzero();
  19.  
  20.   total = n * sz;
  21.   if ((r = _malloc(total)) != NULL) {
  22.     _bzero(r, total);
  23.   }
  24.   return(r);
  25. }
  26.  
  27. void * calloc(n, sz)
  28. size_t n, sz;
  29. {
  30.   return _calloc((unsigned long) n, (unsigned long) sz);
  31. }
  32.